<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title></title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
    </style>
</head>

<body class="iframeBody">
    <div class="Wrapper">
      <form id="formSet">
        <div class="fieldset1 tabel_col clearFix">
            <div class="fieldBox col_33">
                <div class="label">项目名称</div>
                <div class="field">
                    <input name="prjNm" id="prjNm" type="text" readonly="readonly" class="ui-textbox" value="${prjNm}" onclick="prjDetailBtn()">
                </div>
            </div>
            <div class="fieldBox col_33">
                <div class="label">合同号</div>
                <div class="field">
                    <input name="lsCntNo" id="lsCntNo" type="text" readonly="readonly" class="ui-textbox" value="${lsCntNo}">
                </div>
            </div>
            <div class="fieldBox col_33">
                <div class="label">客户姓名</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" readonly="readonly" class="ui-textbox" value="${cstNm}">
                </div>
            </div>
            <div class="fieldBox col_33">
                <div class="label">项目类型</div>
                <div class="field">
                    <input name="prjTypCdNm" id="prjTypCdNm" type="text" readonly="readonly" class="ui-textbox" value="${prjTypCdNm}">
                </div>
            </div>
            <div class="fieldBox col_33">
                <div class="label">当前机构</div>
                <div class="field">
                    <input name="insNm" id="insNm" type="text" readonly="readonly" class="ui-textbox" value="${insNm}">
                </div>
            </div>
        </div>
          <br/>
          <div class="caption TC">
              <span class="title" style="color: #00877a;">----预筛选合规机构组合----</span>
          </div>
          <br/>
          <div id="preInsList" class="sq-grid"></div>
          <br/>
          <div class="caption TC">
              <span class="title" style="color: #00877a;">----当前项目其他合规机构-----</span>
          </div>
          <br/>
          <div id="insList" class="sq-grid"></div>
        <div class="btnsBox TC">
          <span id="cutResIns" class="sq-button sq-button-round">切换机构</span>
        </div>
      </form>
    </div>

    <script>
    var prjId = "${prjId}";
    var preInsListJSON = [];
    <c:if test="${not empty preInsList}"> preInsListJSON = ${preInsList}; </c:if>
    var insListJSON = [];
    <c:if test="${not empty insList}"> insListJSON = ${insList}; </c:if>
    var insList;
    $(function() {
        $("#formSet").ligerForm({
            validate: true
        });
        var preInsList = $("#preInsList").ligerGrid({
            data:getRows(preInsListJSON),
            dataAction:'local',
            columns: [
                {
                    display: '机构名称', name: 'insNm', minWidth: 300
                },
                { display: '提示信息', name: 'gctDes', align: 'left',
                    render:function(rowdata,rowindex,value){
                        if(rowdata.gctDes!=null){
                            return '<span class="gridTip" style="cursor: pointer;" title="' + rowdata.gctDes + '">' + rowdata.gctDes + '</span>';
                        }
                    } },
                { display: '追加调节费', name: 'feeDes', align: 'left',
                    render:function(rowdata,rowindex,value){
                        if(rowdata.feeDes!=null){
                            return '<span class="gridTip" style="cursor: pointer;" title="' + rowdata.feeDes + '">' + rowdata.feeDes + '</span>';
                        }
                    }
                },
            ],
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            frozen: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            fixedCellHeight: false,
            usePager: false,
            onAfterShowData: function() {
                SetIframe_height();
            }
        });
        insList = $("#insList").ligerGrid({
            data:getRows(insListJSON),
            dataAction:'local',
            columns: [
                {
                    display: '机构名称', name: 'insNm', minWidth: 300
                },
                { display: '提示信息', name: 'gctDes', align: 'left',
                    render:function(rowdata,rowindex,value){
                        if(rowdata.gctDes!=null){
                            return '<span class="gridTip" style="cursor: pointer;" title="' + rowdata.gctDes + '">' + rowdata.gctDes + '</span>';
                        }
                    } },
                { display: '追加调节费', name: 'feeDes', align: 'left',
                    render:function(rowdata,rowindex,value){
                        if(rowdata.feeDes!=null){
                            return '<span class="gridTip" style="cursor: pointer;" title="' + rowdata.feeDes + '">' + rowdata.feeDes + '</span>';
                        }
                    }
                },
            ],
            hideLoadButton: true,
            width: '100%',
            height: 300,
            heightDiff: -2,
            enabledEdit: false,
            isScroll: false,
            checkbox: true,
            frozen: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            fixedCellHeight: false,
            usePager: false,
            onAfterShowData: function() {
                SetIframe_height();
            }
        });

        /**
         * 切换机构
         */
        $('#cutResIns').click(function(event) {
            var selectedRows = insList.getSelectedRows();
            if(selectedRows.length != CommonConstant.C_YN_Y_1){
                top.$.ligerDialog.SQalert({content: "请选择一条要切换的机构", SQ_type: "warning"});
                return;
            }
            var data ={};
            data["prjId"] = prjId;
            data["insResId"] = selectedRows[0].id;
            $.ajax({
                type: 'post',
                dataType:'json',
                data:data,
                url: '<%=path%>/insroute/insRouteInsRes/cutResIns.do',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == CommonConstant.C_YN_Y){
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    }else{
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    })

    function getRows(dataList){
        var data = { Rows: [],total:0};
        if (dataList === undefined){
            return data;
        }
        for (var i = 0; i < dataList.length; i++){
            data.Rows.push(dataList[i]);
            data.total ++ ;
        }
        return data;
    }

    function prjDetailBtn(){
        var fromPrjFlag = true;
        var detailFlag = true;
        Add_navTab('tab_project_detail'+prjId,'项目详情','<%=path%>/project/prjbscinfo/toModifyPage.do?fromPrjFlag='+fromPrjFlag+'&&id='+prjId+'&&detailFlag='+detailFlag);
    }
    </script>
</body>
</html>
